const Article = require('../../models/article')

module.exports = (req,res) => {
  // console.log(req.query);
  const word = new RegExp(req.query.info,'i')
  Article.find({
    $or: [
      { title: { $regex: word } },
      { author:{ $regex: word }}
      ]
  }, (err, articleDoc) => {
    // console.log(articleDoc.length);
    res.status(200).json({
      err_code: 0,
      data: articleDoc,
      message:'搜索成功'
    })
  })
}